package com.atgm.mall.gmmailcoupon.controller;

import com.atgm.common.utils.PageUtils;
import com.atgm.common.utils.R;
import com.atgm.mall.gmmailcoupon.entity.PeriGoodsSaleEntity;
import com.atgm.mall.gmmailcoupon.service.PeriGoodsSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 周边商品优惠
 */
@RestController
@RequestMapping("/gmmallcoupon/perigoodssale")
public class PeriGoodsSaleController {

    @Autowired
    private PeriGoodsSaleService periGoodsSaleService;

    /**
     * 首页获取优惠周边商品信息
     * @return
     */
    @GetMapping("/list")
    public R getPeriGoodsSaleList(@RequestParam Map<String, Object> params) {
        PageUtils page = periGoodsSaleService.queryPage(params);
        return R.ok().setData(page);
    }

    /**
     * 根据id获取周边商品信息
     * @param ids
     * @return
     */
    @GetMapping("/info")
    public R getPeriGoodsSaleByPeriGoodsIds(@RequestParam("ids") List<Long> ids) {
        List<PeriGoodsSaleEntity> list = periGoodsSaleService.queryPeriGoodsSaleByPeriGoodsIds(ids);
        return R.ok().setData(list);
    }

}
